<?php if (!defined('BASEPATH'))exit('No direct script access allowed');
/**
 * 余卷宝模块控制器
 */
class Mquan extends MY_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('super_partner_model');
    }
    function index() {
        $this->display("mquan/index.html");
    }
    
    //申请操作
    function apply(){
        if($_POST){
            $truename = isset($_POST['mName']) ? trim($_POST['mName']) : "";
            $mobile = isset($_POST['mMobile']) ? trim($_POST['mMobile']) : "";
            $email = isset($_POST['mEmail']) ? trim($_POST['mEmail']) : "";
            $img = isset($_POST['mImg']) ? trim($_POST['mImg']) : "";
            
            if(!$truename){
                $mess['reqStatus'] = false;
                $mess['errorMsg'] = "姓名不能为空哦";
                echo JSON($mess);exit;
            }
            if(!$mobile){
                $mess['reqStatus'] = false;
                $mess['errorMsg'] = "手机不能为空哦";
                echo JSON($mess);exit;
            }
            if(!$truename){
                $mess['reqStatus'] = false;
                $mess['errorMsg'] = "请上传股票截图哦";
                echo JSON($mess);exit;
            }
            //数据
            $data = array();
            $data["truename"] = $truename;
            $data["mobile"] = $mobile;
            $data["email"] = $email;
            $data["stock_img"] = $img;
            $data["create_time"] = time();
            $result = $this->super_partner_model->insert($data);
            if($result){
                $mess['reqStatus'] = true;
                $mess['errorMsg'] = "申请成功";
                echo JSON($mess);exit;
            }else{
                $mess['reqStatus'] = false;
                $mess['errorMsg'] = "申请失败，请稍后重试！";
                echo JSON($mess);exit;
            }
        }
    }
}
